<template>
    <div>
        <van-card v-for="(item, index) in gwc" :key="index" :num="item.count" :price="item.goods_price"
            :title="item.goods_name" :thumb="item.goods_big_logo">
            <template #footer>
                <van-button size="mini" @click="jia(item, index)">按钮</van-button>
                <van-button size="mini" @click="add(item)">按钮</van-button>
            </template>
        </van-card>
    </div>
    <div>
        <van-submit-bar :price="zj" :button-text="`提交(${gs})`" @submit="onSubmit" class="zj">
            <van-checkbox v-model="checked">全选</van-checkbox>
        </van-submit-bar>
    </div>
</template>

<script setup>
import { useStore } from '../../store';
import { storeToRefs } from 'pinia';
import { showConfirmDialog } from 'vant';
import { useRouter } from 'vue-router';
let router = new useRouter()
const { gwc,zj,gs } = storeToRefs(useStore())
const { GOU, sc, jian } = useStore()
const jia = (item, index) => {
    if (item.count == 1) {
        showConfirmDialog({
            title: '标题',
            message:
                '您确定要删除吗',
        })
            .then(() => {
                // on confirm
                 sc(item, index)
            })
            .catch(() => {
                // on cancel
            });
       
    }
    else {
        jian(item)
    }
}
const add = (item) => {
    GOU(item)
}
const onSubmit = ()=>{
    router.push('/zhi')
}
</script>

<style>
.zj {
    margin-bottom: 50px;

}
</style>